/*
 * @Author: Aro
 * @Date: 2024-01-25 09:42:06
 */
// 通用app顶部导航栏

import 'package:flutter/material.dart';
import 'package:flutter_baseui/utils/screen_util.dart';
import 'package:flutter_baseui/widgets/gaussian_blur_kit.dart';
import 'package:flutter_baseui/widgets/gesture_kit.dart';
import 'package:flutter_baseui/widgets/model/icon_event_model.dart';

class NavBarKit extends StatefulWidget {
  const NavBarKit({
    super.key,
    required this.title,
    this.leftConfig,
    this.rightConfig,
  });

  final IconEventModel? leftConfig;
  final IconEventModel? rightConfig;
  final String title;

  @override
  State<NavBarKit> createState() => _NavBarKitState();
}

class _NavBarKitState extends State<NavBarKit> {
  @override
  Widget build(BuildContext context) {
    return PreferredSize(
      preferredSize: Size(0, ScreenUtil.navBarHeight(context)),
      child: GaussianBlurKit(
        child: Padding(
          padding: EdgeInsets.only(top: ScreenUtil.statusBarHeight(context)),
          child: SizedBox(
            height: ScreenUtil.appBarHeight,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                GestureKit(
                  onTap: widget.leftConfig?.onTap,
                  borderRadius: BorderRadius.circular(40),
                  child: SizedBox(
                    width: ScreenUtil.appBarHeight,
                    height: ScreenUtil.appBarHeight,
                    child: Container(
                      decoration:
                          const BoxDecoration(color: Colors.transparent),
                      child: widget.leftConfig?.icon,
                    ),
                  ),
                ),
                Expanded(
                  child: Center(
                    child: Text(
                      widget.title,
                      style: const TextStyle(fontSize: 22),
                    ),
                  ),
                ),
                GestureKit(
                  onTap: widget.rightConfig?.onTap,
                  borderRadius: BorderRadius.circular(30),
                  child: SizedBox(
                    width: ScreenUtil.appBarHeight,
                    height: ScreenUtil.appBarHeight,
                    child: Container(
                      decoration:
                          const BoxDecoration(color: Colors.transparent),
                      child: widget.rightConfig?.icon,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
